home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 7
/
Aminet 7 - August 1995.iso
/
Aminet
/
comm
/
net
/
NGMan.lha
/
NGMan
next >
Wrap
Text File
|
1995-06-16
|
21KB
|
674 lines
/*************************************************/
/* NGMan Version 1.3 by Steve Collins */
/* email steve@stuffs.demon.co.uk */
/* http://metro.turnpike.net/C/cheeky/INDEX.HTML */
/*************************************************/
/*******************************************************/
/* Make sure the following five entries suit your setup */
/*******************************************************/
NEWS_DIR = "UUlib:" /* Directory that contains your Newsgroups file */
NEWS_NAME = "Newsgroups" /* Name of your Newsgroups file */
NEW_DIR = "UUspool:" /* Directory that contains your new groups file */
/* --- */
NEW_NAME = "Newgroups" /* Name of your new groups file */
/* --- */
/* If you don't have a new groups file you will */
/* still be able to use NGMan but all options */
/* relating to it will be unavailable. */
ACTIVE_LIST = "UUlib:active.newsgroups" /* Path to your active newsgroup list */
/*************************************************/
/* The following can also be changed if you want */
/*************************************************/
IGNORE = "" /* Default ignore pattern, see docs for more info */
DEF_MAX = 10 /* Max entries to be shown per page. */
/* 13 max suggested for non interlace screens */
/* 30 max for interlace/DBLPAL screens */
DEF_DAYS = 2 /* Default days to keep messages */
CONFIRM = 1 /* 1 = Confirm deletion, 0 = Don't confirm */
SORT_NEW = 1 /* 1 = Display new groups sorted alphabetically */
/* 0 = Display unsorted */
SCREEN = "" /* Public screen you want the requesters to appear on. */
/* Rexxreqtools will try to open it's requesters on */
/* whatever screen it was called from, but sometimes */
/* it seems to need a little persuasion ;) */
REQWIDTH = 60 /* Prevents looong entries from running off the edge of */
/* the requester. '60' is a good general setting but you */
/* can alter it if you want. */
PROGTXT = 1 /* 1 = Show info about current search & ignore pattern in */
/* search progress window, */
/* 0 = Don't show info */
/*******************************/
/* Alter the rest at your peril*/
/*******************************/
OPTIONS RESULTS
SIGNAL on BREAK_C
NL = '0a'x
CSI = '9b'x
ESC = '1b'x
PLAIN_TXT = CSI||'30'x||'6d'x
BOLD_TXT = CSI||'31'x||'6d'x
BEEP = '07'x
TITLE = "NGMan 1.3"
DATE = "14/6/95"
CHANGES = 0
CTAG = "rtez_flags=ezreqf_centertext"
if SCREEN ~= "" then STAG = "rt_pubscrname = " || SCREEN
else STAG = ""
KEYWORD = ""
MAIN_FILE = NEWS_DIR || NEWS_NAME
TEMP_FILE = "T:" || NEWS_NAME
NEW_LIST = NEW_DIR || NEW_NAME
NEW_TEMP = "T:" || NEW_NAME
HITLIST = "T:hitlist.tmp"
if ~ exists(NEWS_DIR || NEWS_NAME) then do
say "Can't find" NEWS_DIR || NEWS_NAME NL "..check configuration"
exit
end
if ~ exists("libs:rexxreqtools.library") then do
say "Can't find rexxreqtools.library, aborting.."
exit
end
if ~ show('L',"rexxreqtools.library") then do
addlib('rexxreqtools.library',0,-30,0)
end
address command
'copy' MAIN_FILE 'to T: NOREQ QUIET'
call CREATE_NEWTMP
call UPDATE_VARS
/********** The Initial requester **********/
MAIN:
SHOWN = 1
call rtezrequest("-" TOTAL "Newsgroups found in" NEWS_DIR || NEWS_NAME"-" NL,
CHANGES "changes made","View|Add|Browse|Search|About|Save & Exit|Abort",TITLE,STAG CTAG,)
if rtresult = 0 then do
call DELFILE(TEMP_FILE)
call DELFILE(HITLIST)
call DELFILE(HITLIST".old")
call DELFILE(NEW_TEMP)
exit
end
if rtresult = 1 & TOTAL >= 1 then signal VIEW /* Go to VIEW and possibly on to EDIT/DELETE */
if rtresult = 1 & TOTAL = 0 then signal MAIN /* No Newsgroups so nothing to view */
if rtresult = 2 then do /* ADD selected */
SOURCE = "MAIN"
call ADD
signal MAIN
end
if rtresult = 3 then do
call rtezrequest("Browse which file..","Active|Hitlist|New",TITLE,STAG,)
if rtresult = 0 then do; BROWSE_LIST = NEW_TEMP; BROWSETXT = "newgroups"; end
if rtresult = 2 then do; BROWSE_LIST = HITLIST".old"; BROWSETXT = HITS "matches on '"KEYWORD"'"; end
if rtresult = 1 then do; BROWSE_LIST = ACTIVE_LIST; BROWSETXT = "active newsgroups"; end
call BROWSE
signal MAIN
end
if rtresult = 4 then do
call rtezrequest("Search which file..","Active|Hitlist|New",TITLE,STAG,)
if rtresult = 0 then SEARCH_LIST = NEW_TEMP
if rtresult = 2 then SEARCH_LIST = HITLIST".old"
if rtresult = 1 then SEARCH_LIST = ACTIVE_LIST
call SEARCH
signal MAIN
end
if rtresult = 5 then do; call ABOUT; signal MAIN; end /* Show the about requester */
if rtresult = 6 then do
call SAVE
call DELFILE(HITLIST)
call DELFILE(HITLIST".old")
exit
end /* Quit, saving changes */
/**************** VIEW selected *****************/
/* First create the body text for the requester */
/************************************************/
VIEW:
CHECK = 0
BODYTEXT = ""
SHOWN_OLD = SHOWN
CHECK_OLD = CHECK
VIEW2:
do i = SHOWN to TOTAL
if ENTRY.i = "" then iterate
TEXT = ENTRY.i
if length(TEXT) > REQWIDTH then TEXT = left(TEXT,REQWIDTH) ">>>"
BODYTEXT = BODYTEXT "("i")" TEXT || NL
SHOWN = SHOWN + 1
CHECK = CHECK + 1
if CHECK = DEF_MAX then leave
end
select
when TOTAL <= DEF_MAX then do
GDGTS = "-|Leave|Edit|Delete|Sort|Add|-" /* Only one page */
RTAGS = "rtez_defaultresponse = 2"
end
when SHOWN = TOTAL + 1 then do
GDGTS = "-|Leave|Edit|Delete|Sort|Add|<<" /* Last page */
RTAGS = "rtez_defaultresponse = 2"
end
when SHOWN - CHECK = 1 then do
GDGTS = ">>|Leave|Edit|Delete|Sort|Add|-" /* First page */
RTAGS = "rtez_defaultresponse = 1"
end
otherwise do
GDGTS = ">>|Leave|Edit|Delete|Sort|Add|<<" /* Intermediate pages */
RTAGS = "rtez_defaultresponse = 1"
end
end
/************ Display the requester ************/
/***** with options to EDIT, DELETE or ADD *****/
VIEW_REQ:
if TOTAL = 0 then BODYTEXT = "" /* No Newsgroups found */
call rtezrequest(BODYTEXT NL || " " SHOWN - 1 "shown," (TOTAL + 1) - SHOWN "remaining..",GDGTS,TITLE,RTAGS STAG,)
if rtresult = 2 then do; SHOWN = 0; signal MAIN; end /* FINISHED */
if rtresult = 1 & SHOWN = TOTAL + 1 then do; signal VIEW_REQ; end /* MORE but none left to show*/
if rtresult = 1 then do; signal VIEW; end /* MORE */
if rtresult = 0 then do /* BACK */
if SHOWN - CHECK = 1 then do; SHOWN = 1; signal VIEW; end
if SHOWN > TOTAL then SHOWN = SHOWN - (CHECK + DEF_MAX)
else SHOWN = SHOWN_OLD - CHECK
signal VIEW
end
/********** ADD selected **********/
if rtresult = 6 then do
ADD:
GROUP = rtgetstring(,"Enter an Newsgroup.."NL,
"(blank to cancel)",TITLE,"OK",CTAG STAG,)
if rtresult = "" | rtresult = 0 then do
if SOURCE = "MAIN" then do; drop SOURCE; signal MAIN; end
else signal VIEW_REQ
end
DAYS = rtgetstring(DEF_DAYS,"Enter days to keep"NL,
"(blank to cancel)",TITLE,"OK",CTAG STAG,)
if rtresult = "" | rtresult = 0 then do
if SOURCE = "MAIN" then do; drop SOURCE; signal MAIN; end
else signal VIEW_REQ
end
TEXT = GROUP
if length(TEXT) > REQWIDTH then TEXT = left(TEXT,REQWIDTH) ">>>"
call rtezrequest("Following entry to be added to you Newsgroups file"NL,
TEXT DAYS,"OK|Cancel",TITLE,CTAG STAG,)
if rtresult = 0 & SOURCE = "MAIN" then return
if rtresult = 0 & SOURCE ~= "MAIN" then signal VIEW_REQ
NEW = TOTAL + 1
ENTRY.NEW = GROUP DAYS
DAYS.NEW= DAYS
GROUP.NEW = GROUP
TOTAL = TOTAL + 1
CHANGES = CHANGES + 1 /* Update CHANGES */
call UPDATE_TMP /* Update T:Newsgroups.. */
call UPDATE_VARS /* Update the variables.. */
SHOWN = SHOWN_OLD /* Restore other variables to */
CHECK = CHECK_OLD /* original settings, to ensure */
BODYTEXT = "" /* we return to the page that we */
/* were called from. */
if SOURCE = "MAIN" then do; drop SOURCE; signal MAIN; end
signal VIEW2 /* Recompile text for VIEW requester */
end
/*********** SORT Selected **********/
if rtresult = 5 then do
address command
'sort' TEMP_FILE TEMP_FILE
CHANGES = CHANGES + 1 /* Update CHANGES */
call UPDATE_VARS /* Update the variables */
/* from the modified file in T: */
SHOWN = SHOWN_OLD /* Restore other variables to */
CHECK = CHECK_OLD /* original settings, to ensure */
BODYTEXT = "" /* we return to the page that we */
signal VIEW2 /* were called from. */
end
/*********** EDIT selected **********/
if rtresult = 3 then do
if TOTAL = 0 then signal MAIN /* No Newsgroups so nothing to edit */
ACTION = "edit.."
MINI = SHOWN - CHECK
MAXI = SHOWN - 1
call GETINDEX
if RESULT = 0 then signal MAIN
EDIT: /* Jump back here if RE-EDIT selected */
NEW_GROUP = rtgetstring(GROUP.INDEX,"Edit Newsgroup name..",TITLE,"OK",CTAG STAG,)
if NEW_GROUP = "" then NEW_GROUP = GROUP.INDEX
NEW_DAYS = rtgetstring(DAYS.INDEX,"Edit days to keep..",TITLE,"OK",CTAG STAG,)
if NEW_DAYS = "" then NEW_DAYS = DAYS.INDEX
/* If no alterations are made then return straight to view requester */
if NEW_GROUP = GROUP.INDEX & NEW_DAYS = DAYS.INDEX then signal VIEW_REQ
TEXT = NEW_GROUP
if length(TEXT) > REQWIDTH then TEXT = left(TEXT,REQWIDTH) ">>>"
call rtezrequest(TEXT NEW_DAYS,"OK|Re-Edit|Abort",TITLE,CTAG STAG,)
if rtresult = 0 then signal VIEW_REQ
if rtresult = 2 then signal EDIT
ENTRY.INDEX = NEW_GROUP NEW_DAYS
GROUP.INDEX = NEW_GROUP
DAYS.INDEX = NEW_DAYS
CHANGES = CHANGES + 1 /* Update CHANGES */
call UPDATE_TMP /* Update T:Newsgroups */
call UPDATE_VARS /* Update the variables.. */
SHOWN = SHOWN_OLD /* Restore other variables to */
CHECK = CHECK_OLD /* original settings, to ensure */
BODYTEXT = "" /* we return to the page that we */
signal VIEW2 /* were called from. */
end
/*********** DELETE selected ***********/
if rtresult = 4 then do
if TOTAL = 0 then signal MAIN
ACTION = "delete.."
MINI = SHOWN - CHECK
MAXI = SHOWN - 1
call GETINDEX
if RESULT = 0 then signal MAIN
if CONFIRM = 1 then do
call rtezrequest("Confirm delete entry for" GROUP.INDEX"?","OK|ABORT",TITLE,CTAG STAG,)
if rtresult = 0 then signal MAIN
end
ENTRY.INDEX = ""
CHANGES = CHANGES + 1 /* Update CHANGES */
call UPDATE_TMP /* Update T:Newsgroups */
call UPDATE_VARS /* Update the variables.. */
if TOTAL = 0 then signal MAIN
SHOWN = SHOWN_OLD /* Restore other variables to */
CHECK = CHECK_OLD /* original settings, to ensure */
BODYTEXT = "" /* we return to the page that we */
/* were called from. */
if SHOWN > TOTAL then SHOWN = SHOWN - DEF_MAX /* Prevents blank view requester */
/* when deleted entry was last entry */
/* and displayed on its own */
signal VIEW2
end
/********** SEARCH selected from MAIN requester **********/
SEARCH:
if SEARCH_LIST = HITLIST".old" & ~exists(HITLIST".old") then do
call rtezrequest("You haven't searched for anything yet","OK",TITLE,STAG,)
return
end
call open(HLIST,HITLIST,WRITE)
if ~open(SLIST,SEARCH_LIST,READ) then do
if SEARCH_LIST = NEW_TEMP then ERRORTXT = "No new groups available"
else ERRORTXT = "Can't open" SEARCH_LIST
call rtezrequest(ERRORTXT,"OK",TITLE,STAG,)
return
end
HITS = 0
IGNORED = 0
SKIP = 0
GETKEY:
KEYWORD = rtgetstring(KEYWORD,"Enter search string (Case insensitive)" NL "-=Blank to cancel=-",TITLE,"OK",CTAG STAG,)
if KEYWORD = "" | rtresult = 0 then do
call close(SLIST)
call close(HLIST)
call DELFILE(HITLIST)
return
end
if words(KEYWORD) > 1 then do
call rtezrequest("-Only one keyword allowed-",OK,TITLE,STAG,)
KEYWORD = compress(word(KEYWORD,1))
end
SEARCH_REQ:
if IGNORE = "" then IGNORETXT = "(Ignore disabled)"
else IGNORETXT = "(Ignore pattern = "IGNORE")"
call rtezrequest("Searching '"SEARCH_LIST"' for keyword '"KEYWORD"'"NL,
IGNORETXT,"OK|EDIT IGNORE|EDIT KEYWORD|ABORT",TITLE,CTAG STAG,)
if rtresult = 0 then do; call close(SLIST); call close(HLIST); return; end
if rtresult = 2 then do
IGNORE = rtgetstring(IGNORE,"Enter new pattern..",TITLE,"OK",CTAG STAG,)
signal SEARCH_REQ
end
if rtresult = 3 then signal GETKEY
/* Open the SEARCH PROGRESS window */
call open(progress_window,'RAW:100/100/400/100/'TITLE '(Control-C to abort)')
if PROGTXT = 1 then do
call writech(progress_window,"Keyword >" BOLD_TXT||KEYWORD||PLAIN_TXT NL)
call writech(progress_window,"Ignore >" BOLD_TXT||IGNORE||PLAIN_TXT NL)
call writech(progress_window,"(*) = match (-) = ignored" NL)
end
call seek(SLIST,0,B)
do forever
TARGET = word(readln(SLIST),1)
if eof(SLIST) then leave
CHECK = index(upper(TARGET),upper(KEYWORD))
if CHECK = 0 then iterate
if CHECK >= 1 then do
call IGNORE_CHECK
if result = 1 then do; call writech(progress_window,"-" ); IGNORED = IGNORED + 1; end
if result = 0 then do
HITS = HITS + 1
call writech(progress_window,"*" )
call writeln(HLIST,TARGET)
end
end
end
SEARCH_ABORTED:
call close(SLIST)
call close(HLIST)
call close(progress_window)
if HITS ~= 0 then do
call DELFILE(HITLIST'.old')
address command
'rename 'HITLIST 'to 'HITLIST'.old'
end
if HITS = 0 then do
call rtezrequest("No matches found containing '"KEYWORD"'","OK",TITLE,STAG,)
return
end
call rtezrequest(HITS + IGNORED "matches found," IGNORED "ignored"NL,
"-"HITS "remain-","VIEW|CANCEL",TITLE,STAG CTAG,)
if rtresult = 0 then do
return
end
if rtresult = 1 then do
BROWSE_LIST = HITLIST".old"
BROWSETXT = HITS "matches on '"KEYWORD"'"
call BROWSE
end
return
/*************************** BROWSE routine ****************************/
/********** *Must be passed file as argument for BROWSE_LIST* **********/
BROWSE:
if BROWSE_LIST = HITLIST".old" & ~exists(HITLIST".old") then do
call rtezrequest("You haven't searched for anything yet","OK",TITLE,STAG,)
return
end
if open(BLIST,BROWSE_LIST,READ) ~= 1 then do
if BROWSE_LIST = NEW_TEMP then ERRORTXT = "No new groups available"
else ERRORTXT = "Can't open" SEARCH_LIST
call rtezrequest(ERRORTXT,"OK",TITLE,STAG,)
return
end
BODYTEXT = ""
x = 0
PAGE = 1
LAST = DEF_MAX
do until eof(BLIST) /* Do until the end of the file is found */
BODYTEXT = "" /* Clear the BODYTEXT variable */
POS.x = seek(BLIST,0,CURRENT) /* Store the current position in the file in case BACK is selected */
do i = 1 to DEF_MAX
NG.i = readln(BLIST)
if NG.i = "" | eof(BLIST) then do
REPORT = "..end of file"
LAST = i
leave
end
else REPORT = ""
BODYTEXT = BODYTEXT i || ")" word(NG.i,1) NL
end
BODYTEXT = BODYTEXT REPORT
call rtezrequest("Browsing" BROWSETXT || NL || "PAGE" PAGE NL NL || BODYTEXT,">>|ADD|Leave|<<",TITLE,STAG,)
if rtresult = 3 then do; call close(BLIST); return; end /* Leave selected */
if rtresult = 0 then do /* BACK selected */
if PAGE = 1 then do /* If already on first page just */
call seek(BLIST,0,BEGIN) /* 'seek' the start of the file */
iterate
end
BACK = x - 1
call seek(BLIST,POS.BACK,BEGIN)
x = x - 1
PAGE = PAGE - 1
iterate
end
if rtresult = 2 then do
ACTION = "Add.."
MINI = 1
if eof(BLIST) then MAXI = min(i,LAST-1)
else MAXI = DEF_MAX
if MAXI = 0 then leave /* NEW BIT */
call GETINDEX
if RESULT = 0 then iterate
call rtezrequest("Confirm add group new group - '"word(NG.INDEX,1)"'","OK|CANCEL",TITLE,STAG,)
if rtresult = 0 then iterate
else do
NEW = TOTAL + 1
ENTRY.NEW = word(NG.INDEX,1) DEF_DAYS
DAYS.NEW = DEF_DAYS
GROUP.NEW = word(ENTRY.NEW,1)
TOTAL = TOTAL + 1
CHANGES = CHANGES + 1 /* Update CHANGES */
call UPDATE_TMP /* Update T:Newsgroups */
call UPDATE_VARS /* Update the variables.. */
end
end
PAGE = PAGE + 1
x = x + 1
end
call close(BLIST)
return
/*********** The ABOUT requester ***********/
ABOUT:
call rtezrequest(TITLE "by Steve Collins" DATE NL NL,
"If you find this script useful OR you want"NL,
"to report a bug OR you have a suggestion as to"NL,
"how to improve it then please drop me a line "NL,
"and I'll also let you know of all updates" NL NL,
"Thanks,"NL NL,
"Send me a quid and I'll send you ALMan - The ultimate alias manager!"NL NL,
"steve@stuffs.demon.co.uk"NL,
"http://metro.turnpike.net/C/cheeky/INDEX.HTML","OK",TITLE,STAG,)
return
/********* The SAVE routine **********/
SAVE:
call DELFILE(NEWS_DIR || NEWS_NAME || ".bak")
call DELFILE(NEW_TEMP)
address command
'rename' NEWS_DIR || NEWS_NAME 'TO' NEWS_DIR || NEWS_NAME || ".bak" 'QUIET'
'copy' TEMP_FILE 'to' NEWS_DIR 'QUIET NOREQ'
call DELFILE(TEMP_FILE)
return
/********** GET index of entry to modify **********/
GETINDEX:
INDEX = rtgetlong(,"Enter index of entry to" ACTION || NL || BODYTEXT,TITLE,"OK|Cancel",STAG "rtgl_min =" MINI "rtgl_max =" MAXI,)
if rtresult = 0 then return 0
return INDEX
/********** Update T:Newsgroups with any changes **********/
UPDATE_TMP:
if open('AS',TEMP_FILE,WRITE) ~= 1 then do
call rtezrequest("Can't open Newsgroups file in T:","ABORT",TITLE,STAG,)
return
end
do i = 1 to TOTAL
if ENTRY.i = "" then iterate
call writeln('AS',ENTRY.i)
end
call close('AS')
return
/********** Update the variables with new entries in T:Newsgroups **********/
UPDATE_VARS:
if open('AS',TEMP_FILE,READ) ~= 1 then do
call rtezrequest("Can't open Newsgroups file in T:","ABORT",TITLE,STAG,)
exit
end
TOTAL = 0 /* Reset the TOTAL variable */
do until eof('AS')
LINE = readln('AS') /* Read each line of the Newsgroups file in T: */
if index(LINE,"#") | LINE = "" then iterate /* If # or "" found then iterate */
TOTAL = TOTAL + 1 /* Increase TOTAL by one for each Newsgroup found */
ENTRY.TOTAL = LINE /* Assign the GROUP + DAYS to the ENTRY. variable */
GROUP.TOTAL = word(LINE,1) /* Extract the GROUP and assign to GROUP. */
DAYS.TOTAL = word(LINE,2) /* Extract the DAYS and assign to DAYS */
end
call close('AS')
return
/*********** Other stuff ************************/
BREAK_C:
signal SEARCH_ABORTED
/************************************************/
CREATE_NEWTMP:
if ~open(NEW,NEW_LIST,READ) then do
return 0
end
call open(LIST,NEW_TEMP,WRITE)
do forever
STRING = readln(NEW)
if eof(NEW) then leave
if STRING = "" then leave
if ~verify(compress(STRING,xrange(0,9)),"//-::",) then iterate
call writeln(LIST,STRING)
end
call close(LIST)
if SORT_NEW = 1 then do
address command
'sort' NEW_TEMP NEW_TEMP
end
return 1
/************************************************/
DELFILE:
parse arg file
if exists(file) then do
address command
'delete' file 'QUIET'
return 1
end
else return 0
/************************************************/
IGNORE_CHECK:
if IGNORE = "" then return 0
do y = 1 to words(IGNORE)
CHECK = index(upper(TARGET),upper(word(IGNORE,y)))
if CHECK = 0 then iterate /* No match so continue with comparison */
if CHECK >= 1 then return 1 /* Match found so return 1 to confirm */
end /* End of loop */
return 0 /* No matches found so return 0 */